


/*
'===============================================================================
'  HNG.Portal.BL.TblMenuManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Windows.Forms;
namespace HNG.Portal.BLL
{
	public class TblMenuManagerBase
	{
	    
		#region ColumnNames
		
				public const String Field_Id="Id";
				
				public const String Field_LangId="LangId";
				
				public const String Field_ParentId="ParentId";
				
				public const String Field_TenDanhMucCha="TenDanhMucCha";
				
				public const String Field_TieuDe="TieuDe";
				
				public const String Field_MoTa="MoTa";
				
				public const String Field_Url="Url";
				
				public const String Field_ShowType="ShowType";
				
				public const String Field_DanhMucId="DanhMucId";
				
				public const String Field_DanhMucDetailId="DanhMucDetailId";
				
				public const String Field_ViTri="ViTri";
				
				public const String Field_ThuTu="ThuTu";
				
				public const String Field_Target="Target";
				
				public const String Field_TrangThai="TrangThai";
				
		#endregion	
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public TblMenuManagerBase()
		{
			// Nothing for now.
		}
		public DataTable Clone()
		{
			DataTable dt = new DataTable();
						
			
			dt.Columns.Add(Field_Id,typeof(int));
			
						
			
			dt.Columns.Add(Field_LangId,typeof(string));
			
						
			
			dt.Columns.Add(Field_ParentId,typeof(int));
			
						
			
			dt.Columns.Add(Field_TenDanhMucCha,typeof(string));
			
						
			
			dt.Columns.Add(Field_TieuDe,typeof(string));
			
						
			
			dt.Columns.Add(Field_MoTa,typeof(string));
			
						
			
			dt.Columns.Add(Field_Url,typeof(string));
			
						
			
			dt.Columns.Add(Field_ShowType,typeof(string));
			
						
			
			dt.Columns.Add(Field_DanhMucId,typeof(int));
			
						
			
			dt.Columns.Add(Field_DanhMucDetailId,typeof(int));
			
						
			
			dt.Columns.Add(Field_ViTri,typeof(string));
			
						
			
			dt.Columns.Add(Field_ThuTu,typeof(int));
			
						
			
			dt.Columns.Add(Field_Target,typeof(string));
			
						
			
			dt.Columns.Add(Field_TrangThai,typeof(bool));
			
			            
            return dt;			
		}
			
		public TblMenuEntity Convert_Entity(TblMenuEntity _TblMenuEntity,TblMenuEntity _TblMenuEntity_XML)
		{	
			
				
			_TblMenuEntity.Id= _TblMenuEntity_XML.Id;
				
			_TblMenuEntity.LangId= _TblMenuEntity_XML.LangId;
				
			_TblMenuEntity.ParentId= _TblMenuEntity_XML.ParentId;
				
			_TblMenuEntity.TenDanhMucCha= _TblMenuEntity_XML.TenDanhMucCha;
				
			_TblMenuEntity.TieuDe= _TblMenuEntity_XML.TieuDe;
				
			_TblMenuEntity.MoTa= _TblMenuEntity_XML.MoTa;
				
			_TblMenuEntity.Url= _TblMenuEntity_XML.Url;
				
			_TblMenuEntity.ShowType= _TblMenuEntity_XML.ShowType;
				
			_TblMenuEntity.DanhMucId= _TblMenuEntity_XML.DanhMucId;
				
			_TblMenuEntity.DanhMucDetailId= _TblMenuEntity_XML.DanhMucDetailId;
				
			_TblMenuEntity.ViTri= _TblMenuEntity_XML.ViTri;
				
			_TblMenuEntity.ThuTu= _TblMenuEntity_XML.ThuTu;
				
			_TblMenuEntity.Target= _TblMenuEntity_XML.Target;
				
			_TblMenuEntity.TrangThai= _TblMenuEntity_XML.TrangThai;
				
			
			return _TblMenuEntity;
		}	
		
			
		public void InsertCollection(EntityCollection _Collection)
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                adapter.SaveEntityCollection(_Collection);
            }
		}

		public TblMenuEntity Insert(TblMenuEntity TblMenuEntity)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(TblMenuEntity, true);
			}
			return TblMenuEntity;
		}

		
		public TblMenuEntity Insert(int Id, string LangId, int ParentId, string TenDanhMucCha, string TieuDe, string MoTa, string Url, string ShowType, int DanhMucId, int DanhMucDetailId, string ViTri, int ThuTu, string Target, bool TrangThai)
		{
			TblMenuEntity _TblMenuEntity = new TblMenuEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblMenuEntity.Id = Id;
				_TblMenuEntity.LangId = LangId;
				_TblMenuEntity.ParentId = ParentId;
				_TblMenuEntity.TenDanhMucCha = TenDanhMucCha;
				_TblMenuEntity.TieuDe = TieuDe;
				_TblMenuEntity.MoTa = MoTa;
				_TblMenuEntity.Url = Url;
				_TblMenuEntity.ShowType = ShowType;
				_TblMenuEntity.DanhMucId = DanhMucId;
				_TblMenuEntity.DanhMucDetailId = DanhMucDetailId;
				_TblMenuEntity.ViTri = ViTri;
				_TblMenuEntity.ThuTu = ThuTu;
				_TblMenuEntity.Target = Target;
				_TblMenuEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblMenuEntity, true);
			}
			return _TblMenuEntity;
		}

		public TblMenuEntity Insert(string LangId, int ParentId, string TenDanhMucCha, string TieuDe, string MoTa, string Url, string ShowType, int DanhMucId, int DanhMucDetailId, string ViTri, int ThuTu, string Target, bool TrangThai)
		{
			TblMenuEntity _TblMenuEntity = new TblMenuEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_TblMenuEntity.LangId = LangId;
				_TblMenuEntity.ParentId = ParentId;
				_TblMenuEntity.TenDanhMucCha = TenDanhMucCha;
				_TblMenuEntity.TieuDe = TieuDe;
				_TblMenuEntity.MoTa = MoTa;
				_TblMenuEntity.Url = Url;
				_TblMenuEntity.ShowType = ShowType;
				_TblMenuEntity.DanhMucId = DanhMucId;
				_TblMenuEntity.DanhMucDetailId = DanhMucDetailId;
				_TblMenuEntity.ViTri = ViTri;
				_TblMenuEntity.ThuTu = ThuTu;
				_TblMenuEntity.Target = Target;
				_TblMenuEntity.TrangThai = TrangThai;
				adapter.SaveEntity(_TblMenuEntity, true);
			}
			return _TblMenuEntity;
		}

		public bool Update(TblMenuEntity _TblMenuEntity)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(TblMenuFields.Id == _TblMenuEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_TblMenuEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}
		
		public bool Update(TblMenuEntity _TblMenuEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_TblMenuEntity, filter);
				toReturn = true;
			}
			return toReturn;
		}

		public bool Update(int Id, string LangId, int ParentId, string TenDanhMucCha, string TieuDe, string MoTa, string Url, string ShowType, int DanhMucId, int DanhMucDetailId, string ViTri, int ThuTu, string Target, bool TrangThai)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblMenuEntity _TblMenuEntity = new TblMenuEntity(Id);
				if (adapter.FetchEntity(_TblMenuEntity))
				{
				
					_TblMenuEntity.LangId = LangId;
					_TblMenuEntity.ParentId = ParentId;
					_TblMenuEntity.TenDanhMucCha = TenDanhMucCha;
					_TblMenuEntity.TieuDe = TieuDe;
					_TblMenuEntity.MoTa = MoTa;
					_TblMenuEntity.Url = Url;
					_TblMenuEntity.ShowType = ShowType;
					_TblMenuEntity.DanhMucId = DanhMucId;
					_TblMenuEntity.DanhMucDetailId = DanhMucDetailId;
					_TblMenuEntity.ViTri = ViTri;
					_TblMenuEntity.ThuTu = ThuTu;
					_TblMenuEntity.Target = Target;
					_TblMenuEntity.TrangThai = TrangThai;
					adapter.SaveEntity(_TblMenuEntity, true);
					toReturn = true;
				}
			}
			return toReturn;
		}

		public bool Delete(int Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblMenuEntity _TblMenuEntity = new TblMenuEntity(Id);
				if (adapter.FetchEntity(_TblMenuEntity))
				{
					adapter.DeleteEntity(_TblMenuEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("TblMenuEntity", null);
			}
		}
		
		
		public int DeleteById(int Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByLangId(string LangId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByParentId(int ParentId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ParentId == ParentId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTenDanhMucCha(string TenDanhMucCha)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TenDanhMucCha == TenDanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTieuDe(string TieuDe)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TieuDe == TieuDe);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMoTa(string MoTa)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByUrl(string Url)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByShowType(string ShowType)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ShowType == ShowType);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDanhMucId(int DanhMucId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.DanhMucId == DanhMucId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDanhMucDetailId(int DanhMucDetailId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.DanhMucDetailId == DanhMucDetailId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByViTri(string ViTri)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ViTri == ViTri);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByThuTu(int ThuTu)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTarget(string Target)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Target == Target);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByTrangThai(bool TrangThai)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("TblMenuEntity", filter);
			}
			return toReturn;
		}
		

		
		public TblMenuEntity SelectOne(int Id)
		{
			TblMenuEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				TblMenuEntity _TblMenuEntity = new TblMenuEntity(Id);
				if (adapter.FetchEntity(_TblMenuEntity))
				{
					toReturn = _TblMenuEntity;
				}
			}
			return toReturn;
		}

		// Return EntityCollection
		public EntityCollection SelectAll()
		{
			EntityCollection _TblMenuCollection = new EntityCollection( new TblMenuEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, null, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}

		
		// Return EntityCollection
		public EntityCollection SelectById(int Id)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(int Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByLangId(string LangId)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByLangIdRDT(string LangId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.LangId == LangId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByParentId(int ParentId)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ParentId == ParentId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByParentIdRDT(int ParentId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ParentId == ParentId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTenDanhMucCha(string TenDanhMucCha)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TenDanhMucCha == TenDanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTenDanhMucChaRDT(string TenDanhMucCha)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TenDanhMucCha == TenDanhMucCha);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTieuDe(string TieuDe)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TieuDe == TieuDe);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTieuDeRDT(string TieuDe)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TieuDe == TieuDe);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByMoTa(string MoTa)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMoTaRDT(string MoTa)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.MoTa == MoTa);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByUrl(string Url)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByUrlRDT(string Url)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByShowType(string ShowType)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ShowType == ShowType);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByShowTypeRDT(string ShowType)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ShowType == ShowType);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDanhMucId(int DanhMucId)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.DanhMucId == DanhMucId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDanhMucIdRDT(int DanhMucId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.DanhMucId == DanhMucId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByDanhMucDetailId(int DanhMucDetailId)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.DanhMucDetailId == DanhMucDetailId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDanhMucDetailIdRDT(int DanhMucDetailId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.DanhMucDetailId == DanhMucDetailId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByViTri(string ViTri)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ViTri == ViTri);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByViTriRDT(string ViTri)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ViTri == ViTri);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByThuTu(int ThuTu)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByThuTuRDT(int ThuTu)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.ThuTu == ThuTu);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTarget(string Target)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Target == Target);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTargetRDT(string Target)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.Target == Target);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection
		public EntityCollection SelectByTrangThai(bool TrangThai)
		{
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_TblMenuCollection, filter, 0, null);
			}
			return _TblMenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByTrangThaiRDT(bool TrangThai)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _TblMenuCollection = new EntityCollection(new TblMenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(TblMenuFields.TrangThai == TrangThai);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_TblMenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		

	}
}
